package com.example

fun main() {
// println(sum(1))
    //如果使用具名传值可以不用在乎顺序
//    println(sum(b = 2, a = 1))

//    println(blessingFunc("zs",2026))

    /*val getDiscountWords = {goodsName:String,hour:Int ->
        val currentYear = 2027
        "${currentYear}年,双11${goodsName}促销倒计时：$hour 小时"
    }
    showOnBoard("华为手机",getDiscountWords)*/

//    println(bussionessFunc("华为手机",2027))
}

/*fun sum(a: Int, b: Int = 3): Int {
    return a + b
}*/

//unit函数，等于其他语言的void,区别在于void的意思是没有返回类型忽略它，但是它无法解释现代语言的一个重要特征，泛型
//it关键字
/*val blessingFunc:(String)->String = {
    val holiday = "New Year."
    "$it.Happy $holiday"
}*/

//注意箭头后面的括号，加了可能会报错
/*val blessingFunc = {name:String,age:Int ->
    val holiday = "New Year."
    "$name,$holiday,$age"
}*/

fun showOnBoard(goodsName:String,showDiscount:(String,Int)->String) {
    val hour = (1..24).shuffled().last()
    println(showDiscount(goodsName,hour))
}

/*
val bussionessFunc :(String) -> String = {
    val holiday = "New Year."
    "$it.Happy $holiday"
}*/

/*
val bussionessFunc = {
    val holiday = "New Year."
    "Happy $holiday"
}*/

/*val bussionessFunc = {name:String,Year:Int ->
    val holiday = "New Year."
    "$name.Happy $holiday $Year"
}*/
//匿名函数就是lambda